$(function(){
	plugins_init_function.push(load_img_init);
    plugins_config_get_function.push(build_load_img);
    $('#loadImgModal').on('show.zui.modal', function (e) {
        chooseMediaResCallBack = changeLoadImg;
    });
})
function load_img_init(){
	data = panoConfig.loading_img;

	if(data&&data.imgPath&&data.bgPath){
		$('#loadImgModal .modal-body .load_img').attr('src',data.imgPath);
		$('#loadImgModal .modal-body .load_bg').attr('src',data.bgPath);
		$("#loadImgModal .modal-body input[name='bgcolor']").val(data.bgcolor);
		$("#loadImgModal .modal-body input[name='auther']").val(data.auther);
		if (data.isopen=='1') {
	    	$("#loadImgModal .modal-body input[name='isopen']:first").attr('checked',true);
		}else{
			$("#loadImgModal .modal-body input[name='isopen']:last").attr('checked',true);
		}
	    
	}
}
function open_load_img(){
    $("#loadImgModal").modal('show');
}
function changeLoadImg(data) {
	var id = $(openMediaResObj).attr('id');
	// console.log(id);
	if(id == "custom_load_img"){
		$(openMediaResObj).parent().prev().find('.load_img').attr("src", data.src);
    	$('#logoModal .modal-body button:first').show();
	}else if(id == "custom_load_bg"){
		$(openMediaResObj).parent().prev().find('.load_bg').attr("src", data.src);
    	$('#logoModal .modal-body button:last').show();
	}
    
}


function build_load_img(panoConfig){
	var loadObj = {};
	var isopen = $("#loadImgModal .modal-body input[name='isopen']:checked").val();

	loadObj.isopen = isopen;
	loadObj.imgPath = $('#loadImgModal .modal-body .load_img').attr('src');
	loadObj.bgPath = $('#loadImgModal .modal-body .load_bg').attr('src');
	loadObj.bgcolor = $("#loadImgModal .modal-body input[name='bgcolor']").val();
	loadObj.auther = $("#loadImgModal .modal-body input[name='auther']").val();

	panoConfig.loading_img = loadObj;
	console.log(data);
}